﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace CSP.Package.Controls
{
    public partial class CSPSolution : UserControl, IInstallationControl
    {
        public CSPSolution()
        {
            InitializeComponent();
        }

        #region IInstallationControl Members

        protected Installer _form;
        public Installer GetForm()
        {
            return _form;
        }

        public void SetForm(Installer installer)
        {
            _form = installer;
        }

        public bool Next()
        {
            try
            {
                Process proces = new Process();
                proces.StartInfo.FileName = @"setup.exe";
                proces.StartInfo.WorkingDirectory = @"CSPSolution";
                proces.Start();
                proces.WaitForExit();
                if (proces.ExitCode != 0)
                {
                    throw new ApplicationException(CSP.Package.labels.CspInstallError_Unexpected);
                }
            }
            catch (Exception ex)
            {
                this.GetForm().ShowException(ex);
                throw ex;
            }
            return true;

        }

        public void Previous()
        {
        }

        public void Skip()
        {
        }

        #endregion


        private void CSPSolution_Load(object sender, EventArgs e)
        {
            TranslateLiterals();
        }

        private void TranslateLiterals()
        {
            label1.Text = CSP.Package.labels.CSPSolution_Intro;                       
        }
    }
}
